/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "autor", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Autor.findAll", query = "SELECT a FROM Autor a"),
    @NamedQuery(name = "Autor.findByAutId", query = "SELECT a FROM Autor a WHERE a.autId = :autId"),
    @NamedQuery(name = "Autor.findByAutNombre", query = "SELECT a FROM Autor a WHERE a.autNombre = :autNombre"),
    @NamedQuery(name = "Autor.findByAutApellido", query = "SELECT a FROM Autor a WHERE a.autApellido = :autApellido"),
    @NamedQuery(name = "Autor.findByAutOrientacion", query = "SELECT a FROM Autor a WHERE a.autOrientacion = :autOrientacion"),
    @NamedQuery(name = "Autor.findByAutCiudad", query = "SELECT a FROM Autor a WHERE a.autCiudad = :autCiudad")})
public class Autor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "aut_id")
    private Integer autId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "aut_nombre", nullable = false, length = 20)
    private String autNombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "aut_apellido", nullable = false, length = 20)
    private String autApellido;
    @Size(max = 45)
    @Column(name = "aut_orientacion", length = 45)
    private String autOrientacion;
    @Size(max = 25)
    @Column(name = "aut_ciudad", length = 25)
    private String autCiudad;
    @JoinColumn(name = "aut_id_pais", referencedColumnName = "pais_id", nullable = false)
    @ManyToOne(optional = false)
    private Pais autIdPais;

    public Autor() {
    }

    public Autor(Integer autId) {
        this.autId = autId;
    }

    public Autor(Integer autId, String autNombre, String autApellido) {
        this.autId = autId;
        this.autNombre = autNombre;
        this.autApellido = autApellido;
    }

    public Integer getAutId() {
        return autId;
    }

    public void setAutId(Integer autId) {
        this.autId = autId;
    }

    public String getAutNombre() {
        return autNombre;
    }

    public void setAutNombre(String autNombre) {
        this.autNombre = autNombre;
    }

    public String getAutApellido() {
        return autApellido;
    }

    public void setAutApellido(String autApellido) {
        this.autApellido = autApellido;
    }

    public String getAutOrientacion() {
        return autOrientacion;
    }

    public void setAutOrientacion(String autOrientacion) {
        this.autOrientacion = autOrientacion;
    }

    public String getAutCiudad() {
        return autCiudad;
    }

    public void setAutCiudad(String autCiudad) {
        this.autCiudad = autCiudad;
    }

    public Pais getAutIdPais() {
        return autIdPais;
    }

    public void setAutIdPais(Pais autIdPais) {
        this.autIdPais = autIdPais;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (autId != null ? autId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Autor)) {
            return false;
        }
        Autor other = (Autor) object;
        if ((this.autId == null && other.autId != null) || (this.autId != null && !this.autId.equals(other.autId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.autApellido + ", " + this.autNombre ;
    }
    
}
